package com.thunder.soft.ui.adapter;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.view.View;

import androidx.annotation.NonNull;

import com.thunder.soft.R;
import com.thunder.soft.bean.SystemBean;
import com.thunder.soft.common.base.BaseAdapter;
import com.thunder.soft.common.base.BaseViewHolder;
import com.thunder.soft.databinding.AdapterSystem2Binding;
import com.thunder.soft.ui.activity.SystemItemActivity;

import java.util.List;

public class SystemTwoAdapter extends BaseAdapter<SystemBean, AdapterSystem2Binding> {
    @Override
    protected int layoutId(int viewType) {
        return R.layout.adapter_system2;
    }

    @Override
    protected void onBindHolder(AdapterSystem2Binding binding, @NonNull BaseViewHolder<AdapterSystem2Binding> holder,
                                int position, @NonNull SystemBean data, List<Object> payloads) {
        super.onBindHolder(binding, holder, position, data, payloads);
        binding.setSystemBean(getData(position));
        binding.executePendingBindings();
    }

    @Override
    public void onBindViewHolder(@NonNull BaseViewHolder<AdapterSystem2Binding> holder, @SuppressLint("RecyclerView") int position) {
        super.onBindViewHolder(holder, position);

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(view.getContext(),SystemItemActivity.class);
                intent.putExtra("cid",getData(position).getId());
                view.getContext().startActivity(intent);
            }
        });
    }
}